package configuration

import (
	"encoding/json"
	"errors"
	"fmt"
	"kop/modules/configuration/client"
	"kop/util/log"
)

func init() {

	var b = client.Load("NPCTemplate")
	if err := json.Unmarshal(b, &NPCConfigs); err != nil {
		panic(err)
	}

	log.Info("Load NPCTemplate.json success.")
}

type (
	// BOSS配置
	NPCConf struct {
		ID          int32
		Sex         int32 // NPC性别
		AttributeID int32 // 能力ID
	}
)

var (
	NPCConfigs = map[int32]NPCConf{}
)

func GetByNPCID(ID int32) (NPCConf, error) {

	var conf, ok = NPCConfigs[ID]
	if ok {
		return conf, nil
	}

	return NPCConf{}, errors.New(fmt.Sprintf("NPCID not found [%d]", ID))
}
